import * as jwt from 'jsonwebtoken';
import { config } from '../config';

//config.jwtSecret as jwt.Secret
export function generateAccessToken(payload: object): string {
  return jwt.sign(payload, config.jwtSecret, {
      expiresIn: config.jwtExpiresIn,
  }as jwt.SignOptions
  );
}

export function generateRefreshToken(payload: object): string {
  return jwt.sign(payload, config.jwtSecret, {
    expiresIn: config.jwtRefreshExpiresIn,
  }as jwt.SignOptions
  );
}

export function verifyToken(token: string): any {
  return jwt.verify(token, config.jwtSecret);
}
